package gxb.test08;

import java.util.Scanner;

public class ReadId {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入身份证号码：");
        while (sc.hasNext()){
            String s = sc.nextLine();
            Boot boot = new Boot();
            boot.star(s);
        }
    }
}
class Boot {
    public void star(String idCard){
        IdentityCard id = new IdentityCard();
        id.setIdCard(idCard);
        System.out.println(id.toString());
        id.getBirth();
        id.getAge();
    }
}
class IdentityCard{
    String idCard;
    public void setIdCard(String idCard) {
        this.idCard = idCard;
    }
    public void getBirth() {
        String birth = idCard.substring(6,14);
        String year = birth.substring(0,4);
        String mounth = birth.substring(4,6);
        String day = birth.substring(6,8);
        System.out.println("生日："+year+"年" +mounth+"月"+day+"日");
    }
    public void getAge(){
        int nowYear = 2016;
        String Syear =idCard.substring(6,10);
        //设置年龄
        int year = Integer.parseInt(Syear);
        int age = nowYear-year;
        System.out.println("年龄："+age);
    }
    @Override
    public String toString() {
        return "身份证号码："+idCard;
    }
}
